package com.jindi.jacococli.biz.aop.cat;

import com.dianping.cat.Cat;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class CatLogMetricForCountAspect {
    @Pointcut(value = "@annotation(com.jindi.jacococli.biz.aop.cat.CatMetric)")
    public void pointCut() {
    }

    @After(value = "pointCut() && @annotation(catMetric)")
    public void doAfter(CatMetric catMetric) {
        String name = catMetric.name();
        int quantity = catMetric.quantity();
        Cat.logMetricForCount(name, quantity);
    }
}
